29. Exercise: Edit Text Preference Constraints

Exercise Code

In this exercise, you will get to handle input errors to stop our app from crashing if the size value was not a valid input!

Exercise: T06.10-Exercise-EditTextPreferenceConstraints

Edit Text Preference Constraints

Now it's your turn to add some error checks for the Edit Text preference responsible for changing the shape sizes

SOLUTION:
  • Update SettingsFragment to implement OnPreferenceChangeListener
  • Override onPreferenceChange to convert the Preference value to float and show an error message if it failed to do so
  • Add the OnPreferenceChangeListener specifically to the EditTextPreference